import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/common/widgets/widgets.dart';
import 'package:getx_learn/app/routes/app_pages.dart';

import '../controllers/state_manager_demo_controller.dart';

class StateManagerDemoView extends GetView<StateManagerDemoController> {
  const StateManagerDemoView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context: context, title: "状态管理、懒加载"),
      body: ListView(
        children: [
          ListTile(
            title: Text("Obx 使用"),
            subtitle: Text("状态管理 obx"),
            onTap: () {
              Get.toNamed(Routes.OBX_DEMO);
            },
          ),

          Divider(),

          ListTile(
            title: Text("数据响应监听"),
            subtitle: Text("Obx()、GetX<MyController>()、GetBuilder<MyController>()等方式"),
            onTap: () {
              Get.toNamed(Routes.RESPONSE_LISTENER);
            },
          ),

          Divider(),

          ListTile(
            title: Text("防抖、限流"),
            subtitle: Text("ever、everAll、once、debounce、interval"),
            onTap: () {
              Get.toNamed(Routes.ANTI_SHAKE);
            },
          ),

          Divider(),

          ListTile(
            title: Text("依赖注入"),
            subtitle: Text("Get.put、Get.lazyPut"),
            onTap: () {
              Get.toNamed(Routes.DEPENDENCY_INJECTION);
            },
          ),

          Divider(),
          ListTile(
            title: Text("GetxService"),
            subtitle: Text("生命周期跟程序一致，主要用来将全局需要使用的数据存到这里"),
            onTap: () {
              Get.toNamed(Routes.GETX_SERVICE_DEMO);
            },
          ),


          Divider(),
          ListTile(
            title: Text("测试 Bindings"),
            subtitle: Text("可以在项目初始化时把所有需要进行状态管理的控制器进行统一初始化"),
            onTap: () {
              Get.toNamed(Routes.BINDINGS_DEMO);
            },
          ),


        ],
      ),
    );
  }
}
